-- For the users of moreores

if(minetest.get_modpath("moreores")) ~= nil then
--cook
minetest.register_craft({
	type = "cooking",
	output = "orewood:silverwood_hot",
	recipe = "group:orew_silver",
})

minetest.register_craft({
	type = "cooking",
	output = "orewood:mithrilwood_hot",
	recipe = "group:orew_mithril",
})
--craft
minetest.register_craft({
	output = '"orewood:silverwood"',
	recipe = {
		{'group:stone', 'group:wood','group:stone'},
		{'group:wood', 'moreores:silver_ingot','group:wood'},
		{'group:stone', 'group:wood','group:stone'},
	}
})

minetest.register_craft({
	output = '"orewood:mithrilwood"',
	recipe = {
		{'group:stone', 'group:wood','group:stone'},
		{'group:wood', 'moreores:mithril_ingot','group:wood'},
		{'group:stone', 'group:wood','group:stone'},
	}
})

--wooden nodes
minetest.register_node(":orewood:silverwood", {
	description = "Silverwood",
	paramtype2 = "facedir",
	tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png^moreores_mineral_silver.png"},
	is_ground_content = false,
	groups = {orewood_moreores=1,orew_silver=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})

minetest.register_node(":orewood:silverwood_hot", {
	description = "Hot Silverwood",
	tiles = {"default_furnace_top.png", "default_furnace_top.png", "default_coal_block.png^moreores_silver_ingot.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_moreores=1,orew_hot=1,choppy=2,oddly_breakable_by_hand=1},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})

minetest.register_node(":orewood:mithrilwood", {
	description = "Mithrilwood",
	tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png^moreores_mineral_mithril.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_moreores=1,orew_mithril=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})

minetest.register_node(":orewood:mithrilwood_hot", {
	description = "Hot Mithrilwood",
	tiles = {"default_furnace_top.png", "default_furnace_top.png", "default_coal_block.png^moreores_mithril_ingot.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_moreores=1,orew_hot=1,choppy=2,oddly_breakable_by_hand=1},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})
--fake nodes
minetest.register_node(":orewood:silverwood_fake", {
	description = "Fake Silverwood",
	paramtype2 = "facedir",
	tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_tree.png^moreores_mineral_silver.png"},
	is_ground_content = false,
	groups = {orewood_moreores=1,orew_fake=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})

minetest.register_node(":orewood:mithrilwood_fake", {
	description = "Fake Mithrilwood",
	tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_tree.png^moreores_mineral_mithril.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_moreores=1,orew_fake=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})
--papy nodes
minetest.register_node(":orewood:silverpapy", {
	description = "Silverpapy",
	drop = "moreores:silver_lump",
	drawtype = "plantlike",
	stack_max = 999,
	tiles = {"moreores_silver_block.png^orewood_cover_mp.png^[makealpha:255,0,255"},
	inventory_image = "moreores_silver_block.png^orewood_cover_mp.png^[makealpha:255,0,255",
	wield_image = "moreores_silver_block.png^orewood_cover_mp.png^[makealpha:255,0,255",
	paramtype = "light",
	walkable = false,
	is_ground_content = true,
	selection_box = {
		type = "fixed",
		fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
	},
	groups = {snappy=3,flammable=2},
	sounds = default.node_sound_leaves_defaults(),

	after_dig_node = function(pos, node, metadata, digger)
		default.dig_up(pos, node, digger)
	end,
})

minetest.register_node(":orewood:silverpapy_ingot", {
	description = "Silveringotpapy",
	drop = "moreores:silver_ingot",
	drawtype = "plantlike",
	stack_max = 999,
	tiles = {"moreores_silver_block.png^orewood_cover_mf.png^[makealpha:255,0,255"},
	inventory_image = "moreores_silver_block.png^orewood_cover_mf.png^[makealpha:255,0,255",
	wield_image = "moreores_silver_block.png^orewood_cover_mf.png^[makealpha:255,0,255",
	paramtype = "light",
	walkable = false,
	is_ground_content = true,
	selection_box = {
		type = "fixed",
		fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
	},
	groups = {snappy=3},
	sounds = default.node_sound_leaves_defaults(),

	after_dig_node = function(pos, node, metadata, digger)
		default.dig_up(pos, node, digger)
	end,
})

minetest.register_node(":orewood:mithrilpapy", {
	description = "Mithrilpapy",
	drop = "moreores:mithril_lump",
	drawtype = "plantlike",
	stack_max = 999,
	tiles = {"moreores_mithril_block.png^orewood_cover_mp.png^[makealpha:255,0,255"},
	inventory_image = "moreores_mithril_block.png^orewood_cover_mp.png^[makealpha:255,0,255",
	wield_image = "moreores_mithril_block.png^orewood_cover_mp.png^[makealpha:255,0,255",
	paramtype = "light",
	walkable = false,
	is_ground_content = true,
	selection_box = {
		type = "fixed",
		fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
	},
	groups = {snappy=3,flammable=2},
	sounds = default.node_sound_leaves_defaults(),

	after_dig_node = function(pos, node, metadata, digger)
		default.dig_up(pos, node, digger)
	end,
})

minetest.register_node(":orewood:mithrilpapy_ingot", {
	description = "Mithrilingotpapy",
	drop = "moreores:mithril_ingot",
	drawtype = "plantlike",
	stack_max = 999,
	tiles = {"moreores_mithril_block.png^orewood_cover_mf.png^[makealpha:255,0,255"},
	inventory_image = "moreores_mithril_block.png^orewood_cover_mf.png^[makealpha:255,0,255",
	wield_image = "moreores_mithril_block.png^orewood_cover_mf.png^[makealpha:255,0,255",
	paramtype = "light",
	walkable = false,
	is_ground_content = true,
	selection_box = {
		type = "fixed",
		fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
	},
	groups = {snappy=3},
	sounds = default.node_sound_leaves_defaults(),

	after_dig_node = function(pos, node, metadata, digger)
		default.dig_up(pos, node, digger)
	end,
})
--ABMs srpout
minetest.register_abm({
	nodenames = {"orewood:silverwood"},
	neighbors = {"default:water_source"},
	interval = 40,
	chance = 10,
	action = function(pos, node)
	local height = 0
	while node.name == "orewood:silverwood" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:silverpapy"})
	end,
})

minetest.register_abm({
	nodenames = {"orewood:silverwood_hot"},
	neighbors = {"default:lava_source"},
	interval = 40,
	chance = 10,
	action = function(pos, node)
	local height = 0
	while node.name == "orewood:silverwood_hot" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:silverpapy_ingot"})
	end,
})

minetest.register_abm({
	nodenames = {"orewood:mithrilwood"},
	neighbors = {"default:water_source"},
	interval = 40,
	chance = 10,
	action = function(pos, node)
	local height = 0
	while node.name == "orewood:mithrilwood" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:mithrilpapy"})
	end,
})

minetest.register_abm({
	nodenames = {"orewood:mithrilwood_hot"},
	neighbors = {"default:lava_source"},
	interval = 40,
	chance = 10,
	action = function(pos, node)
	local height = 0
	while node.name == "orewood:mithrilwood_hot" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:mithrilpapy_ingot"})
	end,
})
--ABMs grow
minetest.register_abm({
	nodenames = {"orewood:silverpapy"},
	neighbors = {"orewood:silverwood"},
	interval = 50,
	chance = 20,
	action = function(pos, node)
	pos.y = pos.y-1
	local name = minetest.get_node(pos).name
	if name ~= "orewood:silverwood"
	and name ~= "orewood:silverwood" then
		return
	end
	if not minetest.find_node_near(pos, 3, {"group:water"}) then
		return
	end
	pos.y = pos.y+1
	local height = 0
	while node.name == "orewood:silverpapy" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:silverpapy"})
	return true
end,
})

minetest.register_abm({
	nodenames = {"orewood:silverpapy_ingot"},
	neighbors = {"orewood:silverwood_hot"},
	interval = 50,
	chance = 20,
	action = function(pos, node)
	pos.y = pos.y-1
	local name = minetest.get_node(pos).name
	if name ~= "orewood:silverwood_hot"
	and name ~= "orewood:silverwood_hot" then
		return
	end
	if not minetest.find_node_near(pos, 3, {"group:lava"}) then
		return
	end
	pos.y = pos.y+1
	local height = 0
	while node.name == "orewood:silverpapy_ingot" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:silverpapy_ingot"})
	return true
end,
})

minetest.register_abm({
	nodenames = {"orewood:mithrilpapy"},
	neighbors = {"orewood:mithrilwood"},
	interval = 50,
	chance = 20,
	action = function(pos, node)
	pos.y = pos.y-1
	local name = minetest.get_node(pos).name
	if name ~= "orewood:mithrilwood"
	and name ~= "orewood:mithrilwood" then
		return
	end
	if not minetest.find_node_near(pos, 3, {"group:water"}) then
		return
	end
	pos.y = pos.y+1
	local height = 0
	while node.name == "orewood:mithrilpapy" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:mithrilpapy"})
	return true
end,
})

minetest.register_abm({
	nodenames = {"orewood:mithrilpapy_ingot"},
	neighbors = {"orewood:mithrilwood_hot"},
	interval = 50,
	chance = 20,
	action = function(pos, node)
	pos.y = pos.y-1
	local name = minetest.get_node(pos).name
	if name ~= "orewood:mithrilwood_hot"
	and name ~= "orewood:mithrilwood_hot" then
		return
	end
	if not minetest.find_node_near(pos, 3, {"group:lava"}) then
		return
	end
	pos.y = pos.y+1
	local height = 0
	while node.name == "orewood:mithrilpapy_ingot" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:mithrilpapy_ingot"})
	return true
end,
})
end